import Vue from 'vue'
import * as Util from '../components/Util'

let CommonService = {
  install (Vue, options) {
    // 给vue增添对话框显示方法
    Vue.CommonService = Vue.prototype.$CommonService = CommonService
  },

  gasCalculate (model, pregas) {
    return Vue.post('rs/logic/gasfeecalculate', {data: {model: model, isGasValue: 0, value: pregas}}, {resolveMsg: null, rejectMsg: '获取金额失败'})
  },

  feeCalculate (model, preamount) {
    return Vue.post('rs/logic/gasfeecalculate', {data: {model: model, isGasValue: 1, value: preamount}}, {resolveMsg: null, rejectMsg: '获取气量失败'})
  },

  buildSellinggas (model, row) {
    return {
      f_balance: model.f_balance,
      f_curbalance: model.f_curbalance,
      f_meter_type: row.f_meter_type,
      f_payment: model.f_payment,
      f_user_id: model.f_user_id,
      f_userinfo_id: row.f_userinfo_id,
      f_user_name: row.f_user_name,
      f_user_type: row.f_user_type,
      f_gasproperties: row.f_gasproperties,
      f_address: row.f_address,
      f_meter_brand: row.f_meter_brand,
      f_meter_style: row.f_meter_style,
      f_meternumber: row.f_meternumber,
      f_price_id: row.f_price_id,
      f_collection: model.f_collection,
      f_operator: Util.f.name,
      f_charge_state: '有效'
    }
  },
  writeCardParams (params, cardRes) {
    return {
      f_manufacturers: params.factory,
      f_card_id: params.kh,
      f_card_gas: params.ql,
      f_times: params.cs,
      // f_state: ''
      f_police_gas: params.bjql,
      f_operator: Util.f.name,
      f_card_state: cardRes.data.Err,
      f_card_times: cardRes.data.Cs
    }
  }
}

export default CommonService
